<?php
set_time_limit(0);
include_once("config.php");
include_once("YoukuTv.php");
//$Url = "http://www.youku.com/show_page/id_zcbfc1d7a962411de83b1.html";
//$Obj = new YoukuTv($Url, 'xinhuanzhugege', '');

//$Url = "http://www.youku.com/show_page/id_z167eaf66786e11e0a046.html";
//$Obj = new YoukuTv($Url, 'datangshuanglongzhuan', '');

$Url = "http://www.youku.com/show_page/id_z8498e704b67c11e0a046.html";
$Obj = new YoukuTv($Url, 'CrazyMonk2', '');
$Rs = $Obj->getAndParse();
echo "<pre>";
print_r($Rs);
echo "</pre>";
if(!$_DB->result(0, " SELECT COUNT(*) FROM ".$_CONF['db']['tablepre']."tv WHERE title = '{$Rs['title']}';"))
{
	$_TIME = time();
	$TvInsertArr = array(
		'catid'=>9, 
		'typeid'=>0, 
		'title'=>$Rs['title'], 
		'keywords'=>$Rs['title'], 
		'description'=>$Rs['contentshort'], 
		'posids'=>1, 
		'url'=>'', 
		'listorder'=>0, 
		'status'=>99, 
		'sysadd'=>1, 
		'islink'=>0, 
		'username'=>'admin', 
		'inputtime'=>$_TIME, 
		'updatetime'=>$_TIME,
		'year'=>$Rs['year'],
		'area'=>$Rs['area'],
		'tvtype'=>$Rs['type'],
		'rate'=>$Rs['rate'],
		'actor'=>','.implode(',', $Rs['actor']).',',
		'role'=>','.implode(',', $Rs['role']).',',
		'director'=>$Rs['director'],
		'playwright'=>$Rs['playwright'],
		'manager'=>$Rs['manager']	
	);
	$Id = $_DB->inserttable($_CONF['db']['tablepre'].'tv', $TvInsertArr, 1);

	$Content = '<div class="story">'.$Rs['contentlong'].'</div>';
	if(is_array($Rs['subcontentlong']) && $Rs['subcontentlong'])
	{
		foreach($Rs['subcontentlong'] as $Key => $Val)
		{
			$Content .= '<p>[page]</p><div class="story">'.$Val.'</div>';
		}
	}
	$TvDataInsertArr = array(
		'id'=>$Id,
		'content'=>$Content,
		'readpoint'=>0,
		'paginationtype'=>2,
		'maxcharperpage'=>0,
		'paytype'=>0,
		'allow_comment'=>1,
		'voteid'=>0,
		'copyfrom'=>'优酷|0',
		'subtitle'=>implode($Rs['subtitle'], ','),
		'subcontentshort'=>implode($Rs['subcontentshort'], '|||'),
		'subcontentlong'=>implode($Rs['subcontentlong'], '|||'),
		'flash'=>implode($Rs['flash'], ',')
	);
	$_DB->inserttable($_CONF['db']['tablepre'].'tv_data', $TvDataInsertArr, 1);
}
?>